package com.yaolonga.itfc.manager.core;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: yaolong
 * @CreateTime: 2024-10-17  10:11
 * @Description: 系统类型
 * @Version: 1.0
 */
@Getter
public enum SystemType {
    win(Arrays.asList("10","11","10.0","11.0")),
    ubuntu(Arrays.asList("24.04","18.04","22.04","20.04")),
    centos(Arrays.asList()),
    mac(Arrays.asList()),
    unknown(Arrays.asList())
    ;

    /**
     * 网络配置命令
     */
    private final List<String> supportVersions;

    SystemType(List<String> supportVersions) {
        this.supportVersions = supportVersions;
    }

    public static SystemType of(String name) {
        for (SystemType type : SystemType.values()){
            if (type.name().equalsIgnoreCase(name)){
                return type;
            }

            if (name.startsWith(type.name())){
                return type;
            }
        }
        return SystemType.unknown;
    }

    public boolean isSupportVersion(String version) {
        return supportVersions.stream().anyMatch(v -> v.equalsIgnoreCase(version));
    }
}
